<template>
	<el-radio-group v-model="shortType" size="small" class="item-gap" @change="onChange">
		<el-radio-button :label="-15">最近15分钟</el-radio-button>
		<el-radio-button :label="-30">最近半小时</el-radio-button>
		<el-radio-button :label="-60">最近1小时</el-radio-button>
	</el-radio-group>
</template>
<script>
    import { formatTime } from '../../../../utils/jk/jk-tool';

    export default {
        model: {
            prop: 'dateRange',
            event: 'change'
        },
        props: {
            date: {
                type: Array,
                default() {
                    return [];
                }
            },
            type: {
                type: [Number, String],
                default: null
            }
        },
        data() {
            return {
                shortType: null
            };
        },
        methods: {
            onChange(minus) {
                const m = minus * 60 * 1000;
                const timeStr = [formatTime(Date.now() + m), formatTime(Date.now())];
                this.$emit('change', timeStr);
            }
        },
        watch: {
            type: {
                handler(newVal) {
                    this.shortType = newVal;
                },
                immediate: true
            }
        }
    };
</script>
